package com.cy.teducommunitys.com.cy.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cy.teducommunitys.com.common.vo.JsonResult;
import com.cy.teducommunitys.com.cy.entity.Center;
import com.cy.teducommunitys.com.cy.service.ICenterService;
import com.cy.teducommunitys.com.cy.service.impl.BaseServiceImpl;
import com.cy.teducommunitys.com.cy.service.impl.CenterServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 所属中心信息表 前端控制器
 * </p>
 *
 * @author mdzz
 * @since 2019-07-19
 */
@RestController
@RequestMapping("/cy/center")
public class CenterController extends BaseController<Center>{
    private ICenterService svc;

    @Autowired
    public CenterController(ICenterService svc){
        super(svc);
        this.svc = svc;
    }

    @RequestMapping("findAllObjects")
    public JsonResult findAllObjects(Page page, String name){
        HashMap<String,Object> map = null;
        if(name != null && !"".equals(name))
        {
            map = new HashMap<>();
            map.put("name",name);
        }
       return super.findAllObjects(page,map);
    }

    @RequestMapping("findObjectById")
    public JsonResult findObjectById(Integer id){
        return super.findObjectById(id);
    }

    @RequestMapping("saveObject")
    public JsonResult saveObject(Center entity){
        return super.saveObject(entity,entity.getCenterId());
    }

    @RequestMapping("deleteObject")
    public JsonResult deleteObject(Integer id){
        return super.deleteObject(id);
    }
    @RequestMapping("doFindZTreeNodes")
    public JsonResult doFindZTreeNodes(){
        List<Center> list = svc.list();
        return new JsonResult(list);
    }
}

